function getStack () {
  const sta = new Error().stack
  if (typeof sta === 'undefined') {
    return ''
  }
  const sts = sta.split('\n')
  if (typeof sts === 'undefined' || sts.length < 4) {
    return ''
  }
  let log = sts[3].trim()
  const reg = /\(([^()]+)\)/g
  log = log.match(reg)
  return log[0].trim().replace('(', '').replace(')', '')
}
function Log () {
  return {
    debug: function (...args) {
      think.logger.debug(getStack(), ...args)
    },
    info: function (...args) {
      think.logger.info(getStack(), ...args)
    },
    warn: function (...args) {
      think.logger.warn(getStack(), ...args)
    },
    error: function (...args) {
      think.logger.error(getStack(), ...args)
    }
  }
}

module.exports = Log()
